home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_46228.txt < prev    next >
Text File  |  1991-02-27  |  1KB  |  36 lines

  1. -- card: 46228 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10. The "not equal to" operator in C is '!=', the "not" operator is '!', the "and" operator is '&&', and the "or" operator is '||'.  The condition in the following 'if' statement is true:
  11.  
  12.     if (!(4==5) && 6!=7)
  13.                 .
  14.                 .
  15.  
  16. In English, it says:  "if four equals five is NOT true, AND six does not equal seven...".
  17.  
  18. As a shorthand for the 'if' statement*, C provides the ternary (three-operand) conditional operator '?:'.  The value of an expression using this operator depends upon the value of its first operand.  If the first operand is true (non-zero), then the second operand is evaluated; else, the third is evaluated and becomes the value of the expression.  The operator may be mixed freely with other operators.  For example, the following assigns the value 12 to result:
  19.  
  20.     result = ((5==6) ? 5 : 6) * 2;
  21.  
  22. -- part contents for background part 7
  23. ----- text -----
  24. 146
  25.  
  26. -- part contents for background part 29
  27. ----- text -----
  28. 48179
  29.  
  30. -- part contents for background part 27
  31. ----- text -----
  32. if-else statement
  33.  
  34. -- part contents for background part 20
  35. ----- text -----
  36. if-else statement - p156